Skip to content

Improve error propagation in tree scan code and handle ENOENT and EACCES gracefully#3166

Merged
igaw merged 5 commits intolinux-nvme:masterfrom
igaw:fix-get-handle
Mar 11, 2026
Merged

Improve error propagation in tree scan code and handle ENOENT and EACCES gracefully#3166
igaw merged 5 commits intolinux-nvme:masterfrom
igaw:fix-get-handle

Conversation

@igaw
Copy link
Copy Markdown
Collaborator

@igaw igaw commented Mar 11, 2026

When running the test suite on machine under normal user context, the test might fail because of not enough permissions. While improving the error propagation in the scan code, take the opertunity to handle these errors more gracefully in the tests suites.

Fixes: #3160 #3159 #3155

igaw added 3 commits March 11, 2026 11:37
nvme_ns_get_transport_handle is creating a handle on demand, which can
fail. Thus we need to propagate this error case and not blindly access
the handle later and cause a NULL pointer access.

Signed-off-by: Daniel Wagner <[email protected]>
The scanning can fail due to missing permissions etc. Thus propagate
this error code instead creating invalid objects.

Signed-off-by: Daniel Wagner <[email protected]>
Replace nvme_scan with nvme_scan_topology and ignore any ENOENT and
EACCES. Either the nvme module is not loaded/present or the current
user might now have permissions to access the device.

Signed-off-by: Daniel Wagner <[email protected]>
igaw added 2 commits March 11, 2026 16:26
The problem with this function is that it does several things at once
which prevents fine grained error handling. And almost every user of
this function was not interested in reading a config file.

Thus open code this and handle the ENOENT and EACCES case. For the

Python binding we just ignore any nvme_scan_topology and
nvme_read_config error because this happens inside the global context
constructor

Signed-off-by: Daniel Wagner <[email protected]>
The scan helpers should also return the error code instead the generic -1.

Fixes: f4c6eee ("rrc: return error codes directly")
Signed-off-by: Daniel Wagner <[email protected]>
@igaw
Copy link
Copy Markdown
Collaborator Author

igaw commented Mar 11, 2026

So this version is no passing a test package build: https://build.opensuse.org/package/show/home:wagi:branches:Base:System/nvme-cli

@igaw igaw merged commit fb69b67 into linux-nvme:master Mar 11, 2026
26 checks passed
@igaw igaw deleted the fix-get-handle branch March 11, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libnvme - cpp-dump: crash due to missing transport handle

1 participant